package com.ityj.yygh.sms.service.impl;

import com.ityj.yygh.sms.service.SmsService;
import com.ityj.yygh.sms.utils.SmsSendUtils;
import com.ityj.yygh.vo.sms.SmsVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class SmsServiceImpl implements SmsService {
    @Autowired
    private SmsSendUtils sendUtils;

    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public void smsSend(SmsVo smsVo) {
        String value = (String) redisTemplate.opsForValue().get(smsVo.getPhone());
        if (!StringUtils.isEmpty(value)) {
            log.info("请不要重复发送！");
            return;
        }
        sendUtils.smsSend(smsVo);
    }
}
